<template>
	<view class="">
		<view class="my-list pl-0 pr-0">
			<u-list @scrolltolower="scrolltolower" v-if="dataList.length > 0">
				<u-list-item v-for="(item, index) in dataList" :key="index">
					<view class="item" @click="$u.route('/pages/finance/settlementDetails?id='+item.id)">
						<view class="flex justify-between align-end">
							<view class="">
								<text>{{item.message || '--'}}</text>
								<view class="mt-20 flex align-center fsize-26 line-gray">{{item.createTime}}</view>
							</view>
							<view class="text-red">￥{{item.money}}</view>
						</view>
					</view>
				</u-list-item>
				<u-loadmore 
					:status="loadmore.status" 
					:icon-type="loadmore.iconType" 
					:load-text="loadmore.loadText.loadText" 
					margin-top="40"
					margin-bottom="20" 
					class="coreshop-padding-top-10" 
				/>
			</u-list>
		</view>
		<!-- 无数据时默认显示 -->
		<view class="emptybox" v-if="dataList.length == 0">
			<u-empty icon-size="150" text="暂无数据" mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	// import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		// mixins:[listHeightMixin],
		data() {
			return {
				loadmore:{
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					},
				},
				curNow: 0,
				staffId:0,
				dataList: [],
				searchData: {
					page: 1,
					limit: 10,
					staffId:0,
				}
			}
		},
		onLoad(option) {
			let that = this
			if (option.id) {
				this.staffId = option.id
				this.searchData.staffId=this.staffId
				this.getPageList(this.staffId)
				uni.setNavigationBarTitle({ title:`${option.userName}的结算记录` })
			}else{
				this.getPageList(0)
			}
		},
		methods: {
			sectionChange(index) {
				if (this.curNow === index) return
				this.curNow = index
				this.searchData = this.$options.data().searchData
				if(this.staffId){
					this.searchData.staffId = this.staffId
				}
				this.searchData
				this.dataList = []
				this.getPageList()
			},
			getPageList(staffId) {
				this.$reqPost('CoreCmsStoreStaffSettlementGetPageList', this.searchData).then(res => {
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.loadmore.status = 'loadmore'
						this.searchData.page++
					} else {
						// 数据已加载完毕
						this.loadmore.status = 'nomore'
					}
				})
			},
			scrolltolower() {
				if (this.loadmore.status === 'loadmore') {
					this.getPageList()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fontWeightNormal{ font-weight: normal;}
	.paddingTop20{ padding-top: 20rpx;}
</style>